<template>
    <div class="ll-root">
        <Headers></Headers>
        <!-- 非购买的 -->
        <div class="X-top" v-if='myTop.photo'>
            <img class="t1-img" :src='myTop.photo.path' />
            <div class='tt-box'>
                <h2>{{myTop.msg}}</h2>
                <hr/>
                <div class='tt-img'>
                    <img :src='myTop.sender.avatar' />
                    <div class='tt-h4'>
                        <h4>
                            {{myTop.sender.username}}
                        </h4>
                        <span>收集到 {{myTop.album.name}}</span>
                    </div>
                    <span class="span">{{myTop.add_datetime_pretty}}</span>
                </div>
            </div>
        </div>
    
        <!-- 下面的请求 -->
        <div class="bots" >
            <div class="x-bot" v-for='bot in myBot'>
                <router-link :to="'/xianshi/last/'+bot.id">
                <img :src='bot.photo.path' />
                <div class="b-box">
                    <p>{{bot.msg}}</p>
                    <span>★ {{bot.favorite_count}}</span>
                </div>
                </router-link>
            </div>
        </div>

        <!-- 猜你喜欢 -->
        <div class="cai">
            <div class="shang" v-for='cc in myCai'>
                <p>{{cc.name}}<span>{{cc.like_count}}人喜欢 </span></p>
                <div class="fa">
                    <img style='margin-right:5px' v-for="ii in cc.covers" :src="ii" />
                </div>
            </div>
            <button>点击查看更多</button>
        </div>
    </div>
</template>

<script>
import Headers from '../components/Headers'
export default {
    components:{
        Headers
    },
    data() {
        return {
            myTop: {},  // 页面上面的请求
            myBot: [],   // 列表的请求
            myCai:[],    // 猜你喜欢
            // isShow:true,
        }
    },
    // 用于调用发送请求的函数
    mounted() {
        this.requestTop();
        this.requestBot();
        console.log(this.$route.params);
        this.requestCai();
    },
    // 用于书写发送请求
    methods: {
        requestTop() {
            this.$http('dt/napi/blog/detail/?', {
                params: {
                    include_fields: ['top_like_users', 'top_forward_users', 'top_like_users', 'tags', 'top_comments', 'related_albums', 'extra_links', 'related_albums.covers', 'root_album', 'share_links', 'share_info', 'atest_events', 'extra_html'],
                    blog_id: this.$route.params.id
                }
            })
                .then(function (res) {
                    // console.dir(res.data.data)
                    this.myTop = res.data.data
                }.bind(this))
        },
        // 表格请求
        requestBot() {
            this.$http('dt/napi/blog/list/by_root_album/?', {
                params: {
                    start: 0,
                    include_fields: ['sender', 'album'],
                    limit: 4,
                    album_id: this.$route.params.albumid,
                    blog_id: this.$route.params.id,
                    _: 1497421663132,
                    // _: this.$router.params.addid,                    
                }
            })
                .then(function (res) {
                    console.dir(res.data.data.object_list)
                    this.myBot = res.data.data.object_list
                    // console.dir(myBot)
                }.bind(this))
        },
        // 猜你喜欢的请求
        requestCai() {
            this.$http('dt/napi/album/list/by_related_blog/?', {
                params: {
                    blog_id: this.$route.params.id,
                }
            })
                .then(function (res) {
                    // console.dir(res.data.data.object_list)
                    this.myCai = res.data.data.object_list  
                    // this.isShow=false  
                }.bind(this))
        }
    }
}
</script>

<style scoped>
.ll-root {
    box-sizing: border-box;
    padding: 0px;
    background-color: #E0E0E0;
}.X-top {
    width: 100%;
    background-color: #FFFFFF;
    box-sizing: border-box;
    padding: 5px;
    border-bottom: 1px solid #999999;    
}
h2,h4 {
    margin: 2px 0px -5px 0px;
    font-size: 14px;
}h2{
    color: black;
    font-weight: 100;
}.tt-box {
    box-sizing: border-box;
    padding: 5px 15px;
}hr {
    border: 1px solid #EFEFEF;
}.tt-img {
    display: flex;
}.tt-img img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 20px;
}.tt-h4 {
    box-sizing: border-box;
    flex-basis: 65%;
}.tt-h4 h4 {
    color: #50A6E0;
}.tt-h4 span {
    font-size: 10px;
    color: black;
    margin-top: -4px;
    padding-bottom: 5px;
}.span {
    font-size: 10px;
    color: #BEBEBE;
    padding-top: 4px;
    position: absolute;
    right: 25px;
}

/* 下面的设计 */
.bots{
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    box-sizing: border-box;
    padding: 5px;
}
.x-bot{
    width: 48%;
    height: 60%;
    margin:3px; 
    background-color: white;
}
.b-box{
    width: 100%;
    background-color: white;
    font-size: 12px;
    color:#D2D2D2;
}
.b-box p{
    margin: 0px;
    color:grey;
}
/* 猜你喜欢(固定) */
.cai{
    margin-top: 20px;
    width: 100%;
    height: 50%;
    background-color: #585858;
    box-sizing: border-box;
    padding: 10px;
}

.shang{
    box-sizing: border-box;
    padding: 0px 20px 10px 20px;
    background-color: white;
    border-radius: 5px;
}
.shang p{
    margin:0px 0px 10px;
    color: grey;
    font-size: 14px;
    padding-top: 10px;
}
.shang p span{
    position: absolute;
    right:45px;
    font-size: 12px;
}
.fa{
    display: flex;
    justify-content: space-between;
    padding-bottom:10px;
    border-bottom: 1px solid #f5f5f5;
}
.gao{
    display: flex;
    justify-content: space-between;
}
.gao img{
     width: 30%;
    height:100px;
}
button{
    width: 100%;
    height:36px;
    line-height: 18px;
    margin: 5px 0px;
    background-color: #E75A46;
    border: 0.5px solid grey;
    border-radius: 3px;
    color: white;
}
.shang .fa img{
    width: 30%;
    height:100px;
}

</style>
